<?php

namespace Core\Session;

use Core\Config;
use Model\User;
use Zend\Session\Container;

class DomainSessionHelper{

    private static $_instance;

    private static function getNameSpaceInstance(){
        if(!self::$_instance)
            self::$_instance =new Container(Config::getSessionNameSpace());
        return self::$_instance;
    }


    public static function setLoginTime($date)
    {
        $mySession = self::getNameSpaceInstance();
        $mySession->loginTime = $date;
    }

    /**
     * @static
     * @return \DateTime
     */
    public static function getLoginTime()
    {
        $mySession = self::getNameSpaceInstance();
        return $mySession->loginTime;

    }

    public static function setCurrentLang($langCode){
        if(!$langCode) return;
        $mySession = self::getNameSpaceInstance();
        $mySession->langCode = $langCode;

    }

    public static function getCurrentLang(){
        $mySession = self::getNameSpaceInstance();
        if(!$mySession->langCode){
            $defaultLang = Config::getDefaultLanguage();
            self::setCurrentLang($defaultLang);
            return $defaultLang;
        }else return $mySession->langCode;
    }


}